//
//  Person.m
//  05-HomeWork
//
//  Created by dllo on 16/7/9.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "Person.h"

@implementation Person
- (instancetype)initWithName:(NSString *)name withAge:(NSInteger)age withSex:(NSString *)sex {
    self = [super init];
    if (self) {
        _age = age;
        _name = name;
        _sex = sex;
    }
    return self;
}

- (NSComparisonResult) compareAge:(Person *)per {
    if (self.age < per.age) {
        return NSOrderedAscending;
    } else if (self.age > per.age){
        return NSOrderedDescending;
    } else {
        return NSOrderedSame;
    }
}
- (NSComparisonResult) compareName:(Person *)per {
    if (self.name < per.name) {
        return NSOrderedAscending;
    } else if (self.name > per.name){
        return NSOrderedDescending;
    } else {
        return NSOrderedSame;
    }
    
}
- (NSComparisonResult) compareSex:(Person *)per {
    if (self.sex < per.sex) {
        return NSOrderedAscending;
    } else if (self.sex > per.sex){
        return NSOrderedDescending;
    } else {
        return NSOrderedSame;
    }
}

- (NSString *)description {

    return [NSString stringWithFormat:@"%@ %@ %ld", _name, _sex, _age];

}
@end
